

var generateOpenMap = function(container, latitude, longitude, longestRunway) {
  
        var fromProjection = new OpenLayers.Projection("EPSG:4326"); // transform from WGS 1984
        var toProjection = new OpenLayers.Projection("EPSG:900913"); // to Spherical Mercator Projection
        var options = {
          controls: []
        };

        map = new OpenLayers.Map(container, options);
        var mapnik         = new OpenLayers.Layer.OSM();
        var position       = new OpenLayers.LonLat(latitude,longitude).transform(fromProjection, toProjection);

        var zoom = 0;

        if (longestRunway <= 5000) zoom = 14;
        else if (longestRunway > 5000 && longestRunway <= 8000) zoom = 13;
        else if (longestRunway > 8000 && longestRunway <= 11000) zoom = 13;
        else if (longestRunway > 11000 && longestRunway <= 15000) zoom = 12;
        else zoom = 12;

 
        //map.addControl(new OpenLayers.Control.PanZoomBar());
        map.addLayer(mapnik);
        map.setCenter(position, zoom );


    map.events.register('zoomend', this, function (event) {
        var x = map.getZoom();
        
        if( x > 14)
        {
            map.zoomTo(14);
        }

        if( x < 12)
        {
            map.zoomTo(12);
        }

    });
};

      
